import { request } from '@/utils/request';
import { LoginParams, UserListQueryParams, AddUserParams, ResetPwd } from '@/api/model/system/userModel';
const Api = {
  captchaImage: '/captchaImage',
  Login: '/login',
  UserList: '/system/user/list',
  User: '/system/user',
  UserInfo: '/system/user/',
  ResetPwd: '/system/user/resetPwd',
};

// 获取登录验证码
export function getCaptchaImage() {
  return request.get({
    url: Api.captchaImage,
  });
}

// 登录
export function Login(data: LoginParams) {
  return request.post({
    url: Api.Login,
    data,
  });
}

// 用户列表
export function getUserList(params: UserListQueryParams) {
  return request.get({
    url: Api.UserList,
    params,
  });
}

// 新增用户
export function addUser(data: AddUserParams) {
  return request.post({
    url: Api.User,
    data,
  });
}

// 用户详情
export function getUserInfo(userId: string | number) {
  return request.get({
    url: Api.UserInfo + userId,
  });
}

// 编辑用户
export function editUser(data: AddUserParams) {
  return request.put({
    url: Api.User,
    data,
  });
}

// 删除用户
export function deleteUser(userIds: string) {
  return request.delete({
    url: Api.UserInfo + userIds,
  });
}

// 重置密码
export function resetPwd(data: ResetPwd) {
  return request.put({
    url: Api.ResetPwd,
    data,
  });
}
